package umich.max.geolocation.featextract.ner;

import java.util.HashMap;
import java.util.List;

import max.nlp.dal.blog.blogger.BloggerBlog;
import max.nlp.dal.blog.blogger.BloggerPost;
import max.nlp.wrappers.ml.weka.WekaFeatureExtractor;

public class LocationBooleanExtractor extends WekaFeatureExtractor<String, Boolean>{

	private static String prefix = "bLOC_";
	
	public LocationBooleanExtractor(){
		super(prefix);
	}
	public HashMap<String, Boolean> extractFeaturesForObject(Object item) {
		BloggerBlog blog = (BloggerBlog) item;
		HashMap<String, Boolean> locsInBlog = new HashMap<String, Boolean>();

		for (BloggerPost post : blog.getPosts()) {
			List<String> locations = post.getLocations();
			if (!locations.isEmpty()) {

				for (String location : locations) {
					location = prefix + location;
					Boolean count = locsInBlog.get(location);
					if (count == null)
						locsInBlog.put(location, true);
				}
			}
		}
		return locsInBlog;
	}
}
